<?php
namespace app\index\controller;

use think\Controller;
use app\model\Category;
use app\model\Commodity;
use app\model\User;

class Index extends Controller{
   //首页
	public function index(){
		$categorys = Category::getListByPage(10);
		// $commoditys = array();
		// foreach ($categorys as $category) {
		// 	$cate_commoditys = Commodity::getCommodityByCategory($category['category_id']);
		// 	$commoditys[$category["category_name"]]["commoditys"] = $cate_commoditys;
		// }
		$category = Category::get(input("category_id"));
		$commoditys = Commodity::getCommodityByCategory(input("category_id"));
		$this->assign("categorys",$categorys);
		$this->assign("now",$category);
		$this->assign("commoditys",$commoditys);
		return $this->fetch();
	}

	public function login(){
		$categorys = Category::getListByPage(10);
		$this->assign("categorys",$categorys);
		return $this->fetch();
	}

	public function register(){
		$categorys = Category::getListByPage(10);
		$this->assign("categorys",$categorys);
		return $this->fetch();
	}

	public function resetPass(){
		$categorys = Category::getListByPage(10);
		$this->assign("categorys",$categorys);
		return $this->fetch();
	}

	public function search(){
		$categorys = Category::getListByPage(10);
		$this->assign("categorys",$categorys);
		$commoditys = Commodity::getCommodityByWord(input("word"));
		$this->assign("commoditys",$commoditys);
		return $this->fetch();
	}
}
?>